{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}


<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->

		<section class="left-section">
			<dl id="leftNav" data-type="message">
				<dt><i class="glyphicon glyphicon-plus"></i> 信息管理</dt>
				{if in_case_array('admin/notice',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/notice/index}">公告管理</a></dd>
				{/if}
				{if in_case_array('admin/information',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/information/index}">资讯管理</a></dd>
				{/if}
				{if in_case_array('admin/singlepage',$priv) || empty($priv)}
				<dd><a class="mb active" href="{url /admin/singlepage/index}">单页管理</a></dd>
				{/if}
				{if in_case_array('admin/brand',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/brand/index}">特约品牌</a></dd>
				{/if}
				{if in_case_array('admin/adPlace',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/adPlace/index}">广告位管理</a></dd>
				{/if}
				{if in_case_array('admin/ad',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/ad/index}">广告管理</a></dd>
				{/if}
			</dl>
		</section>

		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			{include admin.inc.bread}
			<h2 class="header">{$title}</h2>
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<div class="inner-container">
					<form role="form" class="content-add-form form-horizontal" id="content-add-form" autocomplete="off">
						<input type="hidden" value="{$item.image_url}" name="data[old_image]" class="form-control">
						<!--tmpl-fields-->
						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">单页类型 </label>
							<div class="col-sm-4"><select name="data[cate_id]" class="form-control">
								{loop $singleCate $cate}
								<option {if $cate['id']==$item['cate_id']}selected{/if} value="{$cate.id}">{$cate.name}</option>
								{/loop}
							</select>
							</div>
						</div>
						<p class="help-block"></p>
						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>标题 </label>
							<div class="col-sm-4">
							<input  dtype="" class="form-control" maxlength="20" name="data[title]" placeholder="标题" required cname="标题" value="{$item[title]}" />
							<p class="help-block"></p>
							</div>
						</div>

						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">图片上传</label>
							<div class="col-sm-4">
								<div class="fileWrap {$companyInfo[idcard_positive] != ''? 'active':''}">

									<div class="fileUpload">
										<input type="hidden" data-id="imgInput" name="data[image_url]" id="cimg_url"  value="{$companyInfo[idcard_positive]}"/>
										<input class="fileBar" id="upload" name="src" type="text" accept="image/gif, image/jpeg, image/jpg, image/png, image/bmp" />
										<div class="btn_file" >
											<!--<div class="icon_add"><i></i></div>
											<p>图片上传</p>-->
											<span class="icon_add"><i class="glyphicon glyphicon-plus">添加图片</i> </span>
										</div>
									</div>
									<div class="uploaded">
										<a class="btn_re" data-act="reUpload" href="javascript:;">删除重新上传</a>
										<p class="img" data-act="big"><img src="{$companyInfo[idcard_positive]}"/></p>
									</div>
								</div>
							</div>
							<div class="col-sm-3">
								【图片比例为:760x470】
							</div>
						</div>
						<p class="help-block"></p>
						
						<!-- editor -->
						<div class="form-group">
							<label class="col-sm-2 control-label"><span	class="asterisk">*</span>单页内容</label>
							<div class="col-sm-8">
								<textarea class="form-control" cname="单页内容" required name="data[content]" id="editor-content" style="height:400px;visibility:hidden;">{$item[content]}</textarea>
								<p class="help-block"></p>
							</div>
						</div>


						<!-- input -->
						<div class="form-group">
							<label class="col-sm-2 control-label">单页简介 </label>
							<div class="col-sm-4">
								<textarea class="form-control" cname="单页简介" name="data[summary]"  placeholder="单页简介">{$item[summary]}</textarea>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span	class="asterisk">*</span>排序</label>
							<div class="col-sm-4">
								<input  dtype="" class="form-control" maxlength="50" name="data[sort_index]" placeholder="50" required cname="排序" value="{if $item[sort_index]}{$item[sort_index]}{else}50{/if}" />
								<p class="help-block"></p>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span
									class="asterisk">*</span>全屏显示/固定显示</label>
							<div class="col-sm-4">
								<input type="checkbox" id="switch-status" name="data[is_full]" class="bswitch"
									   data-size="small" {if $item[is_full]=='1'}checked{/if} data-on-text="全屏"  data-off-text="固定">

							</div>
						</div>
						<p class="help-block"></p>

						<div class="form-group">
							<label class="col-sm-2 control-label">操作人</label>
							<div class="col-sm-4" style="padding-top: 3px;">{$admin_name}</div>
						</div>
						<p class="help-block"></p>
						<!--tmpl-assocfields-->
						<div class="btn-group btn-group-or">
							<a href="{if $id==''}{$do_add_url}{else}{$do_edit_url}?id={$id}{/if}" class="btnlg mb ajaxproxy"
								proxy='{"method":"post", "location":"{$index_url}"}'>提交保存</a>

						</div>
					</form><!-- content add form -->
				</div>
			</div><!-- end of inner -->
		</section>
	</div>
</div>
{include admin.inc.footer}
<!--tmpl-script-->
<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/informationadd",function (parameter){
		/**--tmpl-templatejavascript--**/
		<!--tmpl-templatejavascript-->
        var $upload = $(".fileWrap");
        parameter.upload_url="{$upload_url}";
		parameter.image_search_url="{$image_search_url}";
		parameter.image_list_url="{$image_list_url}";
		parameter.init();
		parameter.upload({
			datas:['{$item.image_url}'],
            onSuccess : function(data) { //上传一张图片成功回调
                removeImage(data[data.length-2]);   ////当上传多张图片的时候，删除之前的所有图片
                var src = data[data.length-1];
                $upload.find('[data-id="imgInput"]').val(src);
                //图片显示
                $upload.find(".img img").attr("src",src);
                $upload.addClass("active");
            },
            onRemove : function(data) {
				/*$("#cimg_url").val("");*/
                $upload.find('[data-id="imgInput"]').val("");
                $upload.removeClass("active");
                removeImage(data); //用户删除的时候，把图片也连带删除
            },
        });

        $upload.on("click",'[data-act="reUpload"]',function(){
            var $wrap=$(this).closest(".fileWrap");
            //removeImage(data); //用户删除的时候，把图片也连带删除
            $wrap.find('[data-id="imgInput"]').val("");
            $wrap.removeClass("active");
        });
        //放大图片
        $('[data-act="big"]').on('click',function(){
            var src= $(this).children("img")[0].src;
            var height = $(window).height()*0.5+'px';
            var width = $(window).width()*0.5+'px';
            var img = '<img src="'+ src+'" style="width: '+width+';height'+height+'">';
            layer.open({
                type: 1,
                title: false,
                shadeClose: true,
                content:img
            })
        });
	});
	function removeImage(data)
	{
		$.get("/admin/singlepage/del_img?image_url="+data,function(result){});
	}
</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}

		<li ><a class="assoc-page" data-page="{[page]}" {[if curr == page]}class="active"{[/if]} href="javascript:void(0)">{[page]}</a></li> 

		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>

</body>
</html>
